﻿using Castle.Core.Interceptor;
using TestBat.IModels.Base;

namespace TestBat.Models.Interceptors.Domain
{
    public class MarkerInterceptor : Castle.Core.Interceptor.IInterceptor
    {
        private readonly string typeName;

        public MarkerInterceptor(string typeName)
        {
            this.typeName = typeName;
        }

        public void Intercept(IInvocation invocation)
        {
            if (invocation.Method.DeclaringType.Equals(typeof(IMarker)))
            {
                invocation.ReturnValue = typeName;
                return;
            }

            invocation.Proceed();
        }
    }
}
